{extend name="public:layout" /}
{block name="title"}{$moudleName}列表{/block}
{block name="head"}{/block}
{block name="body"}
<div class="wrapper wrapper-content">
    <div class="ibox">
        <div class="ibox-title">
            <ol class="breadcrumb">
                <ol class="breadcrumb">
                    <li class="active"><i class="fa fa-hand-o-right"></i> {$moudleName}列表</li>
                </ol>
            </ol>
        </div>
        <div class="ibox-content">
            <div class="toolbar">
                <div class="pull-left">
                    <button type="button" onclick="CheckAll();" class="btn btn-white">全</button>
                    <button type="button" onclick="CheckOther();" class="btn btn-white">反</button>
                    <a class="btn btn-primary"
                       href="{:url('add',['mid'=>$Request.param.mid,'cid'=>$Request.param.cid])}">
                        <i class="fa fa-plus"></i>&nbsp;添加{$moudleName}
                    </a>
                </div>
                <div class="pull-right">
                    <form class="form-inline" method="post">
                        <div class="form-group">
                            <div class="input-group">
                                <input class="form-control" type="text" placeholder="请输入检索标题"
                                       name="title" value="{$query.title}"/>
                            </div>
                        </div>
                        <button type="submit" class="btn btn-info">
                            <i class="fa fa-search"></i> 搜索
                        </button>
                        <a class="btn btn-white" href="{:url('index',['mid'=>$Request.param.mid])}">
                            <i class="fa fa-trash"></i> 清空
                        </a>
                    </form>
                </div>
                <div class="clearfix"></div>
            </div>
            <table class="table table-bordered" id="grid">
                <thead>
                <tr>
                    <th width="50">#</th>
                    <th width="70">排序</th>
                    <th width="60">图集</th>
                    <th>标题</th>
                    <th width="80">状态</th>
                    <th width="80">操作</th>
                </tr>
                </thead>
                <tbody>
                {volist name="list" id="vo"}
                <tr>
                    <td>
                        <input name="aid[]" type="checkbox" class="checkbox" value="{$vo.aid}" />
                    </td>
                    <td>
                        <input type="text" class="form-control input-sm batchSort" value="{$vo.sort}"
                               name="sort[{$vo.aid}]" />
                    </td>
                    <td>
                        <img src="{$vo.thumb}" style="width:52px;height:52px;" />
                    </td>
                    <td>
                        {$vo.title}
                        {notempty name="vo.flag"}
                        <span class="text-danger">[{$vo.flag}]</span>
                        {/notempty}
                    </td>
                    <td>{$vo.status_text}</td>
                    <td>
                        <a href="{:url('edit',['aid'=>$vo['aid'],'mid'=>$vo['mid'],'cid'=>$vo['cid']])}">编辑</a>
                        <a href="javascript:;" onclick="doAction(this);"
                           data-msg="确认删除吗？" data-url="{:url('del')}" data-params="aid={$vo.aid}&mid={$vo.mid}">删除</a>
                    </td>
                </tr>
                {/volist}
                </tbody>
            </table>
            <div class="p8">
                <div class="pull-left">
                    <div class="form-inline">
                        <button type="button" onclick="upOrder();" class="btn btn-info">
                            <i class="fa fa-sort"></i> 排序
                        </button>
                        <button type="button" onclick="batchDel(CheckboxValue())" class="btn btn-danger">
                            <i class="fa fa-trash"></i> 删除
                        </button>
                        <button type="button" onclick="audit(0);" class="btn btn-inverse">
                            <i class="fa fa-times"></i> 取审
                        </button>
                        <button type="button" onclick="audit(1);" class="btn btn-success">
                            <i class="fa fa-check"></i> 审核
                        </button>
                        <select name="flag" id="flag" class="form-control" style="width:80px;">
                            {volist name="flagList" id="flag"}
                            <option value="{$flag}">{$flag}</option>
                            {/volist}
                        </select>
                        <button type="button" onclick="setFlag('set');" class="btn btn-success">设置</button>
                        <button type="button" onclick="setFlag('esc');" class="btn btn-default">取消</button>
                    </div>
                </div>
                <div class="page-bar">{$list->render()}</div>
                <div class="clearfix"></div>
            </div>
        </div>
    </div>
</div>
{/block}
{block name="script"}
<script type="text/javascript">
    //批量设置属性
    function setFlag(action) {
        var aid = CheckboxValue();
        if (IsMore(aid)) {
            var flag = $('#flag').val();
            var url = "{:url('setFlag')}";
            var params = {'aid': aid, 'mid': "{$Request.param.mid}",flag:flag,action:action};
            doConfirm('你确认要设置属性吗？', url, params, function (data) {
                if (data.code == 1) {
                    rePage();
                }
            });
        }
    }
    //批量删除文章
    function batchDel(aid) {
        if (IsMore(aid)) {
            var url = "{:url('del')}";
            var params = {'aid': aid, 'mid': "{$Request.param.mid}"};
            doConfirm('你确认要删除吗？', url, params, function (data) {
                if (data.code == 1) {
                    rePage();
                }
            });
        }
    }
    //更新排序
    function upOrder() {
        if ($(".batchSort").length == 0) {
            alert('您还没有添加内容！');
            return false;
        }
        var params = $(".batchSort").serialize();
        var url = "{:url('upOrder',['mid'=>$Request.param.mid])}";
        getAjax(url, params, function (data) {
            if (data.code == 1) {
                rePage();
            }
        });
    }
    //批量设置模板
    function setTpl() {
        if ($(".content-tpl").length == 0) {
            alert('您还没有添加内容！');
            return false;
        }
        var params = $(".content-tpl").serialize();
        var url = "{:url('setTpl',['mid'=>$Request.param.mid])}";
        getAjax(url, params, function (data) {
            if (data.code == 1) {
                rePage();
            }
        });
    }
    //取审审核
    function audit(status) {
        var aid = CheckboxValue();
        var mid = "{$Request.param.mid}";
        if (IsMore(aid)) {
            var url = "{:url('setStatus')}";
            var params = {'mid': mid, 'aid': aid, 'status': status};
            doConfirm('确认操作吗？', url, params, function (data) {
                if (data.code == 1) {
                    rePage();
                }
            });
        }
    }
</script>
{/block}